package is.progetto1.aritmeticExpression;

public class IntegerNoSign extends Expression {

	private int value;
	
	public IntegerNoSign(int value){
		if (value < 0) {
			throw new IllegalArgumentException();
		}
		this.value = value;
	}

	public IntegerNoSign(int value, Expression parent) {
		this(value);
		this.parent = parent;
	}

	@Override
	public final int toAssess(Context c) {
		return value;
	}

	@Override
	public final String toString() {
		return new Integer(value).toString();
	}

	@Override
	public final int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((parent == null) ? 0 : parent.hashCode());
		result = prime * result + value;
		return result;
	}

	@Override
	public final boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IntegerNoSign other = (IntegerNoSign) obj;
		if (value != other.value)
			return false;
		return true;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}
}
